<template>
  <div>
    <nav-bar class="nav-bar">
      <template v-slot:center>购物车({{ length }})</template>
      <template v-slot:right
        ><span class="cart-av-bar-right" @click="manageClick">{{
          manageMsg
        }}</span></template
      >
    </nav-bar>
    <cart-list />
    <cart-bottom-bar ref="cartBottomBar" />
  </div>
</template>

<script>
import NavBar from "@/components/common/navbar/NavBar";
//子组件
import CartList from "@/views/cart/childComps/CartList";
import CartBottomBar from "@/views/cart/childComps/CartBottomBar";
import { mapGetters } from "vuex";
export default {
  name: "Cart",
  components: {
    NavBar,
    CartList,
    CartBottomBar,
  },
  data() {
    return { manageMsg: "管理" };
  },
  computed: {
    ...mapGetters({
      length: "cartLength",
    }),
  },
  methods: {
    manageClick() {
      if (this.manageMsg === "管理") {
        this.manageMsg = "取消";
        this.$refs.cartBottomBar.isDelete = true;
      } else {
        this.manageMsg = "管理";
        this.$refs.cartBottomBar.isDelete = false;
      }
    },
  },
};
</script>

<style scoped>
.nav-bar {
  background-color: var(--color-tint);
  color: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}
.cart-av-bar-right {
  display: block;
  width: 100%;
  height: 100%;
  font-size: 13px;
}
</style>
